<html>
<head>
    <title>config</title>
    <style type="text/css">

        table {
            border-collapse: collapse;
            margin: 0 auto;
            text-align: center;
        }

        table td, table th {
            border: 1px solid #cad9ea;
            color: #666;
            height: 30px;

        }

        table thead th {
            background-color: #CCE8EB;
            width: 100px;
            word-break: break-word;
        }

        table tr:nth-child(odd) {
            background: #fff;
        }

        table tr:nth-child(even) {
            background: #F5FAFA;
        }
    </style>

</head>
<script>
    function deleteItem(id) {
        var r = confirm("confirm delete ?");
        if (r == true) {
            deleteResponse(id)
        }
    }
    function editItem(id) {
        window.open("edit?id=" + id)
    }

    function ajaxObject() {
        var xmlHttp;
        try {
            // Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        }
        catch (e) {
            // Internet Explorer
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    alert("您的浏览器不支持AJAX！");
                    return false;
                }
            }
        }
        return xmlHttp;
    }

    function deleteResponse(id) {
        var ajax = ajaxObject();
        ajax.open("delete", "/easyserver/responses/" + id, true);
        ajax.setRequestHeader("Content-Type", "application/json;charset=utf-8");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var response = JSON.parse(ajax.responseText)
                    if (response.code == 1) {
                        location.reload();
                    }

                }

            }

        }
        ajax.send(null);

    }



</script>
<body>
<table width="90%" class="table">
    <tr>
        <th>
            no
        </th>
        <th>
            time
        </th>
        <th>
            description
        </th>
        <th>
            method
        </th>
        <th>
            url
        </th>
        <th>
            response
        </th>
        <th>

        </th>
        <th>

        </th>
    </tr>
{{range $i, $v := .}}
    <tr>
        <td>
        {{$i}}
        </td>
        <td>
        {{formatTime $v.Time}}
        </td>
        <td>
        {{ $v.Description}}
        </td>
        <td>
        {{$v.Method}}
        </td>
        <td>
        {{$v.UrlPath}}
        </td>
        <td>
        {{subLongText $v.ResponseText}}
        </td>
        <td>
            <img width="20" height="20" src="static/img/edit.png" onclick="editItem({{$v.Id}})">
        </td>
        <td>
            <img width="20" height="20" src="static/img/delete.png" onclick="deleteItem({{$v.Id}})">
        </td>
    </tr>
{{end}}
</table>
</form>


</body>
</html>